import Footer from '@/components/footer';
import Header from '@/components/header';
import axios from 'axios';
import type { IGetInitialProps } from 'umi';
import css from './index.less';
const Home = (props: any) => {
  const { data, history } = props;
  const renderStr = (str: string) => {
    if (!str)
      return '昔陈胜，吴广于大泽乡高呼，王侯将相宁有种乎？及后秦灭汉兴，可见人无天生贵胄贫贱之分，盖追求也！<br>吾幼时贫困，生于乡野，里有夙愿，看尽繁华，奈何先天不足，穷且益坚，唯勤学不缀，方有所成！<br>时做诗约：<br>愿化鲲鱼，<br>浮游海底，<br>一日振翅，<br>鹏程万里。';
    return str.replace(/\\n/g, '<br />');
  };
  return (
    <div className={css.home}>
      <Header history={history} />
      <div className={css.content}>
        <div className={css.con}>
          <div className={css.logo}>
            <img src={require('../../assets/logo.png')} alt="" />
          </div>
          <div
            className={css.text}
            dangerouslySetInnerHTML={{ __html: renderStr(data?.abstract) }}
          />
          <Footer />
        </div>
        <div className={css.r_bg}>
          <img src={require('../../assets/1.jpg')} alt="" />
        </div>
      </div>
    </div>
  );
};
Home.getInitialProps = (async () => {
  const result = await axios.get('https://messln.cn/api/api/home/find');
  return {
    data: result.data.data,
  };
}) as IGetInitialProps;
export default Home;
